﻿using IcicleFramework.Actions;
using IcicleFramework.Components.Renderable;
using Microsoft.Xna.Framework;

namespace ExampleGame.Actions
{
    public class ColorChangeAction : GameAction
    {
        public Color Color { get; set; }

        public ColorChangeAction() { }

        public ColorChangeAction(ColorChangeAction old) 
            : base(old)
        {
            Color = old.Color;
        }

        public override void Update(GameTime gameTime)
        {
            var renderComp = Target != null ? Target.GetComponent<IRenderComponent>() : null;

            if (renderComp != null)
            {
                renderComp.SetShading(Color);
            }

            Finished = true;
        }

        public override IGameAction DeepClone()
        {
            return new ColorChangeAction(this);
        }
    }
}
